package com.zzyl.nursing.mapper.member;

import com.zzyl.nursing.domain.member.Reservation;
import com.zzyl.nursing.vo.member.CreateByTimeVo;
import org.apache.ibatis.annotations.*;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface MemberReservationMapper {

    @Insert("insert into reservation(name,mobile,time,visitor,type,status,create_time,create_by,update_time,update_by,remark) " +
            "values(#{name},#{mobile},#{time},#{visitor},#{type},#{status},#{createTime},#{createBy},#{updateTime},#{updateBy},#{remark})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int add(Reservation reservation);
    @Select("select * from reservation where status = #{status}")
    List<Reservation> page(Integer status);

    /**
     * 查询取消预约数量
     * @param startTime
     * @param endTime
     * @param status
     * @param
     * @return
     */
    List<Reservation> getCancelCount(@Param("startTime") LocalDateTime startTime, @Param("endTime")LocalDateTime endTime,@Param("status") Integer status);
    /**
     * 查询时间段剩余次数
     * @param
     * @return
     */
    List<CreateByTimeVo> getCountByTime(@Param("beginTime") LocalDateTime beginTime,@Param("endTime") LocalDateTime endTime);

    List<Reservation> findByPage();

    @Update("update reservation set status = 2 where id = #{id}")
    int cancel(Long id);
}
